import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import java.io.IOException;

@WebServlet("/upload")
public class file extends HttpServlet {
    protected void service(HttpServletRequest req,HttpServletResponse resp) throws IOException, ServletException {
        Part part = req.getPart("filename");
        String filename = part.getSubmittedFileName();
        long size = part.getSize();
        System.out.println(size);
        String realpath = req.getServletContext().getRealPath("/File");
        System.out.println(realpath);
        part.write(realpath+"/"+filename);
    }
}
